/*
ID: quxiao82
LANG: C++
PROG: fact4
*/
#include <cstdio>
#include <cstdlib>
using namespace std ;

int n;
const int f2 [] = {6, 2, 4, 8};

void Input ()
{
       scanf( "%d", &n);
}

void Solve ()
{
       if ( n == 1 )
      {
             printf( "1\n");
             return;
      }
       int i, tmp, n2, n5;
       int ans = 1;
       n2 = n5 = 0;
       for ( i = 1; i <= n; i ++)
      {
             tmp = i;
             while ( tmp % 2 == 0 )
            {
                   n2 ++;
                   tmp /= 2;
            }
             while ( tmp % 5 == 0 )
            {
                   n5 ++;
                   tmp /= 5;
            }
             ans = (( tmp % 10) * ans) % 10;
      }
       ans = ( ans * f2[( n2- n5)%4] ) % 10;
       printf( "%d\n", ans);
}

int main ()
{
       freopen( "fact4.in", "r" , stdin );
       freopen( "fact4.out", "w" , stdout );

       Input ();
       Solve ();

       return 0;
}
